import java.util.*;
//for arraylist, collections.sort
package drymouth;
public class UserRequest
{

//private data
	private Set <Condition> myConditions;
	
//constructor
	public UserRequest()
	{ myConditions=new HashSet <Condition>();}
	
//accessors
	public Set getConditions()
	{return myConditions;}
	
//mutators
	protected boolean add(Condition c)
	{return myConditions.add(c);} //we can change the access level as needed
	
//compuational methods
	public Condition[] getRelated(int n, SymptomSet s, Set <Condition> conditionSet)
	{
		//returns the n most related conditions to the given symptoms, where
		//symptoms are given though concat_symptoms
		private List <ConditionScore> scores=new ArrayList <ConditionScore> (); //wrapper class to be defined
		private Iterator iter=myConditions.iterator();
		while (iter.hasNext())
		{
			Condition c=iter.next();
			double scoreForC=c.getSimilarityToSymptoms(s);
			scores.add(new ConditionScore(c,scoreForC));
		}
		private Condition[] mostRelated=new Condition[n]; //where we will put the most related conditions
		
		Collections.sort(scores); //see which order sorted, may need to change it up a bit
		//scores should now be sorted because conditionscores are comparable.
		
		for(int i=0;i<n;++i)
		{mostRelated[i]=scores.get(i);}
		
		return mostRelated;
	}

	public Condition[] getRelated(int n, Condition c, Set <Condition> conditionSet)
	{ return getRelated(n,c.getSymptoms(),conditionSet);}
	
	public Condition[] getRelated(int n, String concat_symptoms, Set <Condition> conditionSet)
	{ SymptomSet s=new SymptomSet(concat_symptoms);
		return getRelated(n,s,conditionSet);
	}

}